#include <stdio.h>
#include <stdlib.h>

int main (int argc, char const* argv[])
{
    int n, ah, am, as, bh, bm, bs, ansh, ansm, anss;

    scanf("%d", &n);

    while (n--) {
        scanf("%d %d %d %d %d %d", &ah, &am, &as, &bh, &bm, &bs);

        ansh = ah + bh;
        ansm = am + bm;
        anss = as + bs;

        // 秒进位
        ansm += anss / 60;
        anss = anss % 60;

        // 分进位
        ansh += ansm / 60;
        ansm = ansm % 60;

        printf("%d %d %d\n", ansh, ansm, anss);
    }

    return 0;
}
